package kmi.droid.animatron;

import android.graphics.Canvas;

public class Particle
{
	private Vector2 previousPosition = new Vector2();
	private Vector2 position = new Vector2();
	private float lifetime = 0f;
	

	public Vector2 Velocity = new Vector2();
	public Vector2 Acceleration = new Vector2();
	public float Mass = 0;
	public float Angle = 0;
	public float AngleVelocity = 0;

	public boolean getIsAlive()
	{
		return getLifetime() >= 0;
	}

	public Particle()
	{		
	}

	public void draw(Canvas canvas)
	{
	}

	public void update(float dt)
	{
		setLifetime(getLifetime() - dt);

		Angle = Angle + AngleVelocity * dt;
		Velocity = Vector2.add(Velocity, Vector2.multiply(dt, Acceleration));
		setPosition(Vector2.add(getPosition(), Vector2.multiply(dt, Velocity)));
	}

	public Vector2 getPosition()
	{
		return position;
	}

	public void setPosition(Vector2 position)
	{
		setPreviousPosition(position);
		this.position = position;
	}

	public Vector2 getPreviousPosition()
	{
		return previousPosition;
	}

	private void setPreviousPosition(Vector2 previousPosition)
	{
		this.previousPosition = previousPosition;
	}

	public float getLifetime()
	{
		return lifetime;
	}

	public void setLifetime(float lifetime)
	{
		this.lifetime = lifetime;
	}
}
